package com.ruoyi.hospital.controller.consultationInfo;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.consultationInfo.ConsulationRecord;
import com.ruoyi.hospital.service.consultationInfo.IConsulationRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问诊记录Controller
 * 
 * @author wendao
 * @date 2025-01-21
 */
@RestController
@RequestMapping("/hospital/consulationRecord")
public class ConsulationRecordController extends BaseController
{
    @Autowired
    private IConsulationRecordService consulationRecordService;

    /**
     * 查询问诊记录列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConsulationRecord consulationRecord)
    {
        startPage();
        List<ConsulationRecord> list = consulationRecordService.selectConsulationRecordList(consulationRecord);
        return getDataTable(list);
    }

    /**
     * 导出问诊记录列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:export')")
    @Log(title = "问诊记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConsulationRecord consulationRecord)
    {
        List<ConsulationRecord> list = consulationRecordService.selectConsulationRecordList(consulationRecord);
        ExcelUtil<ConsulationRecord> util = new ExcelUtil<ConsulationRecord>(ConsulationRecord.class);
        util.exportExcel(response, list, "问诊记录数据");
    }

    /**
     * 获取问诊记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(consulationRecordService.selectConsulationRecordById(id));
    }

    /**
     * 新增问诊记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:add')")
    @Log(title = "问诊记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConsulationRecord consulationRecord)
    {
        return toAjax(consulationRecordService.insertConsulationRecord(consulationRecord));
    }

    /**
     * 修改问诊记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:edit')")
    @Log(title = "问诊记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConsulationRecord consulationRecord)
    {
        return toAjax(consulationRecordService.updateConsulationRecord(consulationRecord));
    }

    /**
     * 删除问诊记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:consulationRecord:remove')")
    @Log(title = "问诊记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(consulationRecordService.deleteConsulationRecordByIds(ids));
    }
}
